package com.yuye.excel.base.config;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.BeanUtils;

import com.yuye.excel.base.dto.ExcelLanguageDTO;
/**
 * 
 * 对外的语种转换 接口 
 * 如果需要自定义 语种转换 可以实现该类
 *
 * @author xgf
 * @version C10 2021年1月20日
 * @since SDP V300R003C10
 */
public interface LanguageTransformationInterface {
	
	public static final List<ExcelLanguageDTO> commonLanguageTra = new ArrayList<>();
	
	public static final Map<String, List<ExcelLanguageDTO>> specialLanguageTra = new HashMap<>();
	
	default public void addCommonLanguageTra(ExcelLanguageDTO excelLanguageDTO) {
		commonLanguageTra.add(excelLanguageDTO);
	}
	
	default public void addSpecialLanguageTra(String name, ExcelLanguageDTO excelLanguageDTO) {
		if(specialLanguageTra.get(name) == null) {
			List<ExcelLanguageDTO> list = new ArrayList<>();
			list.add(excelLanguageDTO);
			specialLanguageTra.put(name, list);
			return;
		}
		specialLanguageTra.get(name).add(excelLanguageDTO);
	}
	
	default public void copySpecialLanguageTraForOther(String toName, String fromName) {
		List<ExcelLanguageDTO> list = specialLanguageTra.get(fromName);
		if(list != null && list.size() > 0 ) {
			List<ExcelLanguageDTO> result = new ArrayList<>();
			for (ExcelLanguageDTO excelLanguageDTO : list) {
				if(excelLanguageDTO == null) {
					continue;
				}
				ExcelLanguageDTO excelLanguageDTOLs = new ExcelLanguageDTO();
				BeanUtils.copyProperties(excelLanguageDTO, excelLanguageDTOLs);
				result.add(excelLanguageDTOLs);
			}
			specialLanguageTra.put(toName, result);
			return;
		}
	}
	
	/**
	 * 
	 * 公共的属性 新增
	 *
	 * @author xgf
	 * @return
	 */
	public void commonLanguageTra();
	
	/**
	 * 
	 * 特殊的属性 新增
	 *
	 * @author xgf
	 * @return
	 */
	public void specialLanguageTra();
	
}
